#include <bits/stdc++.h>

using namespace std;

int coins[1000];

struct Node
{
    int deepth = 0;
    long value = 0;
};

char hash1[1000] = {0};

int main()
{

    long amount = 0;
    int n;
    cin >> amount >> n;

    Node st;

    for(int i = 0; i < n; i++)
    {
        cin >> coins[i];
    }

    queue<Node> q;
    q.push(st);

    int result = -1;

    while(!q.empty())
    {
        Node now = q.front();
        // cout << "value = "<< now.value<<"  deepth = "<<now.deepth<<endl;
        q.pop();
        if(now.value == amount)
        {
            result = now.deepth;
            break;
        }
        if(hash1[now.value])
        {
            continue;
        }else{
            hash1[now.value] = 1;
            for(int i = 0; i < n; i++)
            {
                Node temp;
                temp.value = now.value + coins[i];
                temp.deepth = now.deepth + 1;
                if(temp.value <= amount)
                    q.push(temp);
            }
        }
    }

    cout << result;
    return 0;
}